﻿using System;
using System.Drawing;

namespace Emerald
{
    public class Tile
    {
        #region Properties

        public BoardPoint Location;
        public Piece Piece;

        #endregion

        #region Constructors

        public Tile(byte x, byte y)
        {
            Location = new BoardPoint(x,y);
        }

        public Tile(BoardPoint bp)
        {
            Location = bp;
        }

        public byte TileType
        {
            get
            {
                if (null == this.Piece)
                    return 0;

                if (this.Piece.Color == EColor.White)
                {
                    if (this.Piece.State == EState.Unmarked)
                    {
                        return 1;
                    }
                    return 2;
                }

                if (this.Piece.Color == EColor.Red)
                {
                    if (this.Piece.State == EState.Unmarked)
                    {
                        return 3;
                    }
                    return 4;
                }

                throw new Exception("Shouldn't get here.");
            }
        }
        #endregion


        public override string ToString()
        {
            return string.Format("({0},{1})  {2}", Location.X, Location.Y, TileType);
        }
    }
}
